package com.duanruan.bmgl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.duanruan.bmgl.dao.EmployeeMapper;
import com.duanruan.bmgl.entity.Employee;
import com.duanruan.bmgl.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xiaolong
 * @create 2020-08-22 9:27
 * @description 员工service层实现类
 */
@Service("EmployeeServicebmgl")
public class EmployeeServiceImpl implements EmployeeService {

    @Resource(name = "EmployeeMapperbmgl")
    private EmployeeMapper employeeMapper;

    //根据部门id查找部门下所有员工
    @Override
    public List<Employee> findEmployees(String departmentId) {
        QueryWrapper<Employee> wrapper=new QueryWrapper<>();
        wrapper.eq("departmentId",departmentId);
        List<Employee> employees=employeeMapper.selectList(wrapper);
        for(Employee employee:employees){
            if("1".equals(employee.getForm())) employee.setForm("正式员工");
            else if("0".equals(employee.getForm())) employee.setForm("临时员工");
        }
        return employees;
    }

}
